//
// Created by gogoqiu on 2022/2/15.
//

#include <wx/textfile.h>
#include "wx/wx.h"

#define LOG_PATH wxT("/tmp/compass.log")

//增量模式
//必须定义App宏
void add_log(wxString log){
    //WXUSINGDLL;
    //APP_NAME;
    printf( APP_NAME );
    wxDateTime dateTime = wxDateTime::Now();
    wxString t = dateTime.FormatTime();
    wxString tmp;
    tmp.sprintf( "%s:\t%s", t, log );
    wxTextFile file(LOG_PATH);
    file.Open();
    if( !file.Exists() ){
        file.Create();
    }
    if( file.GetLineCount()> 1000 ){
        file.Clear();
    }
    file.AddLine( tmp );
    file.Write();
    file.Close();
}